package test00.lx03;

import java.util.Arrays;
import java.util.Comparator;

/**
 * @author CSY
 * @date 2025 - 04 - 02
 */
public class MainTest01 {
    public static void main(String[] args) {
        Integer[] arr = {1,5,6,2,7,3,4,8,10,50,32,40};
        Arrays.sort(arr, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                //直接两数相减
                //当o2-o1为正数，那么o2排在o1的前面，否则o2在o1的后面
                /*System.out.println(Arrays.toString(arr));
                System.out.println("o1:"+o1);
                System.out.println("o2:"+o2);
                System.out.println(o2 - o1);*/
                return o2-o1;
            }
        });

        System.out.println(Arrays.toString(arr));
    }
}
